//
//  ViewController.swift
//  Guess
//
//  Created by 吴翰林 on 2019/9/8.
//  Copyright © 2019 吴翰林. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var doraGuess: UIImageView!
    @IBOutlet weak var youGuess: UIImageView!
    @IBAction func guess(_ sender: Any) {
        doraGuess.image = UIImage(named: "rock");
        
        let guess = arc4random_uniform(3)
        var result = ""
        if guess == 0{
            result = "you lose"
            youGuess.image = UIImage(named: "scissor")
            
        }else if guess == 1{
            result = "you = dora"
            youGuess.image = UIImage(named: "rock")
        }else{
            result = "you win"
            youGuess.image = UIImage(named: "paper")
            
        }
        let alert = UIAlertController(title: "结果", message: result, preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "确定", style: .default, handler: { _ in
            self.doraGuess.image = nil
            self.youGuess.image = nil
        }))
        present(alert, animated: true, completion: nil)
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }


}

